//#include <iostream>
//using namespace std;
//int main()
//{
//	cout << 1478 << endl;
//	return 0;
//}


#include<bits/stdc++.h>
#include<unordered_map>

using namespace std;

int main()
{
	unordered_map<int, int> hash;
	hash[12]++;
	hash[123]++;
	hash[234]++;
	hash[345]++;
	hash[456]++;
	hash[567]++;
	hash[789]++;
	int month[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	int cnt = 0;
	for (int i = 1; i < 13; i++)
	{
		for (int j = 1; j <= month[i] ;j++)
		{
			long long tmp = 20220000 + i * 100 + j;
			string s = to_string(tmp);
			for (int i = 0; i < 6; i++)
			{
				if (hash.count((s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2]-'0')))
				{
					cnt++;
					break;
				}
			}
		}
	}
	cout << cnt;

	return 0;
}